<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="4" :sm="6">
            <a-form-item label="投诉用户ID" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <j-input placeholder v-model="queryParam.complainantId"></j-input>
            </a-form-item>
          </a-col>
          
          <a-col :md="4" :sm="6">
            <a-form-item label="被投诉用户ID" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <j-input placeholder v-model="queryParam.respondentId"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 21px">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
           <a @click="getDynamicInfo(record)">动态详情</a>
           <a-divider type="vertical" />
          <!-- <a @click="handleEdit(record)">编辑</a> -->
          <a @click="handleDetail(record)">详情</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>

      </a-table>
    </div>

    <complaint-management-modal ref="modalForm" @ok="modalFormOk"></complaint-management-modal>
    
    <!-- 动态详情 -->
    <a-modal v-model="dynamicInfoVisible" title="动态详情" @ok="handleOk">
      <p>头像: &nbsp;
        <a-avatar :src="this.dynamicInfo.avatar" />
        <p>
          <p>用户昵称: &nbsp;{{dynamicInfo.nicakname}}</p>
          <p>ID: &nbsp; {{dynamicInfo.userId}}</p>
          <p>学校: &nbsp; {{dynamicInfo.schoolName}}</p>
          <p>发布时间: &nbsp; {{dynamicInfo.createTime}} </p>
          <p>动态内容: &nbsp; {{dynamicInfo.dynamicContent}}</p>
          
          <div v-if="dynamicInfo.dynamicVideo != '' && dynamicInfo != null">
            视频: &nbsp;
            <a :href="dynamicInfo.dynamicVideo">
              <img :src="dynamicInfo.dynamicVideo +'?x-oss-process=video/snapshot,t_7000,f_jpg,w_1000,h_800,m_fast' "  width="200" height="140" />
            </a>
           </div>
           
            <div  v-if="imgs">
              图片: &nbsp;
              <div v-for="documentImg in imgs">
                <viewer>
                  <img :src="documentImg" width="200" height="140" />
                </viewer>
              </div>
            </div>
           <!---- 动态审核：1待审核，2审核通过，3审核不通过 -->
          <p>点赞数: &nbsp; {{dynamicInfo.likeNum}}</p>
          <p>转发数: &nbsp; {{dynamicInfo.shareNum}}</p>
          <p v-if="dynamicInfo.audit == '1'">
            审核状态: &nbsp; 待审核
          </p>
          <p v-if="dynamicInfo.audit == '2'">
            审核状态: &nbsp; 审核通过
          </p>
          <p v-if="dynamicInfo.audit == '3'">
            审核状态: &nbsp; 不通过
          </p>
    </a-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ComplaintManagementModal from './modules/ComplaintManagementModal'
  import JInput from '@comp/jeecg/JInput'

  export default {
    name: "ComplaintManagementList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      ComplaintManagementModal,
      JInput
    },
    data () {
      return {
        dynamicInfoVisible:false, //动态详情
        dynamicInfo:{},
        description: '投诉管理管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          // {
          //   title:'投诉类型',
          //   align:"center",
          //   dataIndex: 'complaintType'
          // },
          {
            title:'投诉人id',
            align:"center",
            dataIndex: 'complainantId'
          },
          {
            title:'被投诉人id',
            align:"center",
            dataIndex: 'respondentId'
          },
          {
            title:'投诉内容',
            align:"center",
            dataIndex: 'complaints'
          },
          // {
          //   title:'被投诉动态内容',
          //   align:"center",
          //   dataIndex: 'complaints'
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/complaintManagement/complaintManagement/list",
          delete: "/complaintManagement/complaintManagement/delete",
          deleteBatch: "/complaintManagement/complaintManagement/deleteBatch",
          exportXlsUrl: "/complaintManagement/complaintManagement/exportXls",
          importExcelUrl: "complaintManagement/complaintManagement/importExcel",
          
        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getDynamicInfo(record) {
        this.axios.get("/dynamic/dynamic/getDynamicInfo", {
          params: {
            dynamicId: record.dynamicId
          }
        }).then((res) => {
          this.dynamicInfo = res.result;
          //切割  图片
          if(this.dynamicInfo.dynamicImg){
              this.imgs = this.dynamicInfo.dynamicImg.split(",");
          }
          this.dynamicInfoVisible = true;
        })
      },
      handleOk(e) {
        this.dynamicInfoVisible = false;
        this.dynamicInfo = {};
        this.imgs = [];
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>